<?php
/**
 * <https://y.st./>
 * Copyright © 2019 Alex Yst <mailto:copyright@y.st>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org./licenses/>.
**/

$xhtml = array(
	'<{title}>' => 'A levelling curve',
	'takedown' => '2017-11-01',
	'<{body}>' => <<<END
<img src="/img/CC_BY-SA_4.0/y.st./weblog/2019/07/02.jpg" alt="Pink hydrangeas" class="framed-centred-image" width="800" height="480"/>
<section id="diet">
	<h2>Dietary intake</h2>
	<p>
		I didn&apos;t get home until past midnight last night, due to visiting with my father.
		I ended up eating some pretzels before bed because I was so hungry, then getting up late because I hadn&apos;t had time to get to bed, so I didn&apos;t really have breakfast, either.
		And out of lack of time while I studied, I didn&apos;t really have lunch either.
		Altogether, I had 400 grams of pretzels today.
	</p>
	<p>
		For dinner, I made spaghetti with chopped Italian sausage and cashew sauce, totalling 287 grams.
	</p>
</section>
<section id="drudgery">
	<h2>Drudgery</h2>
	<p>
		My discussion post for the day:
	</p>
	<blockquote>
		<p>
			You say that Android and Linux are the same, but that&apos;s not the case at all.
			There are two different Linuxes.
			There&apos;s the Linux operating system and the Linux kernel, on top of which the Linux operating system is built.
		</p>
		<p>
			If we&apos;re talking about the Linux operating system, which is the first Linux you mentioned in your post, it&apos;s very much not the same thing as Android.
			They share a kernel, but the rest of the software stack is different.
			Android does not use the Linux operating system&apos;s core software, aside form the kernel, for the most part.
			There are a couple other shared components, such as the software needed to read Linux filesystems, but nearly the entire Android system is different than Linux.
			Calling Android and the Linux operating system the same thing is like calling a human and a lizard the same thing.
			We share some $a[DNA], having come form a common ancestor, and we can even do many of the same things, such as see with our eyes and walk with our legs, but many of the components are different in very recognisable ways.
		</p>
		<p>
			If we&apos;re talking about the Linux kernel, Android can&apos;t be the same thing as the Linux kernel either, because the Linux kernel is just a kernel, and the Android system is a full operating system that includes said kernel.
			In this case, saying that they&apos;re the same thing is like saying that a head and a human are the same thing.
			A human needs a head to function, and a head is a part of a human, but a head alone is not a human.
			Similarly, Android needs the Linux kernel and the Linux kernel is a part of Android, but the Linux kernel alone isn&apos;t the same thing as Android.
		</p>
	</blockquote>
</section>
<section id="Minetest">
	<h2>Minetest</h2>
	<img src="/img/CC_BY-SA_3.0/minetest.net./weblog/2019/07/02.png" alt="You can&apos;t jump off from ungrabbed checkpoints any more." class="framed-centred-image" width="1024" height="600"/>
	<p>
		I figured out what I want to do for the checkpoint-limiting function.
		At first, I tried defining equations with no real goal in sight, and that didn&apos;t get me anywhere.
		What helped was keeping mushroom spores in mind.
		Whatever exponential function I defined would royally screw over the spore element, because it&apos;s so hard to gain a level with the stack size being as high as I set it.
		It&apos;s already the case that no player will likely use the spore elements for anything because it&apos;s just too hard.
		They have to farm 65535 spores to reach the first level.
		If it takes four stacks to get a second checkpoint, this really isn&apos;t acceptable.
		There should be some sort of scaling mechanism to the exponential equation that takes maximum stack size into account.
		In the extreme case, stack sizes of 65535, the most the engine can handle due to using sixteen-bit, unsigned integers, the growth should be completely linear.
		But how could I define an equation like that?
	</p>
	<p>
		The next thing I thought about was how having one element have an exponential growth in usefulness and another have linear growth, there&apos;s going to come a point in which they intersect.
		After that, the amount of mining needed to get the next checkpoint is going to be so much more astronomical than the spore element&apos;s measly 65535 drops needed.
		All the while, I was also thinking about the levels-showing page I&apos;ve been considering, which would cap out at level 65535 due to technical limitations in the interface.
		After much more thinking, I figured out how I wanted to use these details together.
	</p>
	<p>
		Simply put, 65535 is the maximum level, but an element&apos;s own maximum stack size is the most usefulness you&apos;ll ever get form the element.
		After level 65535, more mining won&apos;t do any good.
		It won&apos;t be that the interface just doesn&apos;t go up any higher, it&apos;ll be the whole mod.
		As for stack sizes, that means that at level 65535, you&apos;ll receive your 99th and final checkpoint slot.
		Oh, also, the first slot opens after mining the first stack.
		I needed a way to find an exponential equation that would meet these criteria, which would convert from usefulness level to the number of stacks you&apos;d need to find to achieve it, then reverse the equation to use logarithms to convert instead from stacks to usefulness.
		I wasn&apos;t sure how to go about it, so I started experimenting with a stack size of 99, and squaring it and cubing it.
		Squaring was too little, but cubing was too much.
		I started changing the exponent up and down slightly, to find the perfect balance.
		None of this was going to work well though, as I&apos;d have a specific equation for stack sizes of 99 and another for stack sizes of 65535.
		What if someone modded in a different stack size?
		My code would fail.
		I needed to do this right by having the computer calculate the exponent based on the given information.
		But how was I to do that?
	</p>
	<p>
		I decided to try an algebra-solving website.
		The awesome part about those sites is that most of them will give you step-by-step directions on how to solve the problem.
		Entering my 99-based equation, I was able to see how the solver computed that into the proper exponent to use.
		The final equation, while I don&apos;t understand it, is to divide the natural log of 65535 by the natural log of the stack size.
		That returns the exponent, which can be cached, then used to calculate the number of checkpoints you get for the number of stacks you&apos;ve mined.
		The best part is that this scales to make elements with low growth rates have terrible potential, but elements that take forever to grind have more potential than you&apos;ll probably have a use for.
		Then again, even the easy elements will have more potential than you probably need.
	</p>
	<p>
		I&apos;ve decided that I want to use this for more than just checkpoints.
		I like the exponential growth rate and growth cap, and think they&apos;ll be useful in encouraging well-rounded farming and mining.
	</p>
	<p>
		With my new equations in hand, I tried to implement the exponential growth system, but somehow got it in reverse.
		Two stacks were allowing about five warp points instead of about five stacks allowing two warp points.
		I couldn&apos;t figure out what I was doing wrong, but after staring at what I&apos;d punched into the algebra solver a while, I noticed that what I&apos;d entered was backwards.
		I wasn&apos;t quite sure the forwards way of entering the numbers though.
		I took a guess, and this time, it told me to swap the numerator and denominator of what I&apos; had before.
		Maybe that&apos;d work?
		And work it did!
		I&apos;m still not sure on how the numbers work, but it now takes one stack to get the first checkpoint, but six stacks to get the second.
		Checkpoint slots from there get progressively harder to get.
	</p>
	<p>
		I&apos;ve modified the code to allow you to only warp from checkpoints you&apos;ve grabbed.
		You can&apos;t simply use checkpoints as jump-off points to reach your bookmarked places.
		You have to commit to them.
		Again, I think this will help prevent their overuse.
	</p>
	<p>
		At work, I realised that this code should be moved from Building Up From Zero to <code>minestats</code>.
		I&apos;m not sure if I&apos;ve mentioned it or not, but I&apos;ve wanted this sort of curved levelling mechanic for about a year now at least, I just haven&apos;t understood the problem well enough to express it mathematically.
		In fact, even today, I didn&apos;t understand how to express the problem.
		However, I was able to understand the solution to the problem well enough to express the <strong>*solution*</strong> algebraically.
		I botched my expression of the problem, and only later at work understood what I&apos;d done wrong specifically, but even that botched expression of the solution was able to lead me to an expression for the problem through the online algebra solver.
		This levelling mechanic isn&apos;t Zero-specific though.
		This is the mechanic I&apos;ve been looking for for any experience-based mod I&apos;ve wanted one for.
	</p>
</section>
END
);
